<wxs src='@/utils/filter.wxs' module='filter'></wxs>
<template>
	<view class="">
		<topTitle :name="`提现`" right back class="bg_w" />
		<view class="content pdx-32 pdy-20">
			<view class="f14 color-6 mb20">提现金额</view>
			<view class="box pdx-20">
				<input type="text" placeholder="请输入金额" v-model="money" class="border-b pdy-30">
				<view class="flex pdt-24 pdb-30">
					<view class="mr16 color-6">佣金金额：{{filter.price(arrMoney || 0,1)}}元</view>
					<view class="pdx-20 color-theme" @click="handArr">全部提现</view>
				</view>
			</view>
			<view class="f14 color-6 mb20">提现方式（提现到银行卡）</view>
			<view class="box flex pdy-40 pdx-20 f-a-c" @click="toBind">
				<view class="mr20 color-9">银行卡</view>
				<view class="color-theme flex-1">{{bankInfo?bankInfo.bankAccountNo:'选择银行卡'}}</view>
				<uni-icons type="forward" class="color6 f14"/>
			</view>
			<!-- <view class="box flex pdy-40 pdx-20" v-else>
				<view class="mr20 color-9">暂无绑定银行卡</view>
				<view class="color-theme" @click="toBind">去绑定银行卡</view>
			</view> -->
			<view class="f14 color-6 mb20">备注</view>
			<view class="box flex pdy-40 pdx-20">
				<textarea placeholder="可输入备注信息" cols="20" class="w h-150"></textarea>
			</view>
			<view class="set bg-theme color-w" @click="set">
				提现
			</view>
			<view class="color-6 fs12 mt16 flex j-c-c">平台将在-13个工作日审核后打款</view>
			<!-- <view class="box money">
				<view class="tit fw">提现金额</view>
				<view class="flex f-a-c j-s-b top">
					<view class="flex f-a-c">
						<view class="f18">￥</view>
						<input type="number" v-model="money" placeholder="请输入提现金额">
					</view>
					<view class="f12 color-47" @click="handArr">全部</view>
				</view>
				<view class="color-eb f12 mt6">
					可提现金额￥{{filter.price(arrMoney || 0,1)}}
				</view>
			</view>
			<view class="box">
				<view class="tit fw">提现到收款银行信息</view>
				<view class="mt10">
					<view v-for="(item,index) in car" :key="index" class="flex f-a-c j-s-b f14 li ">
						<view class="">{{item.name}}</view>
						<input type="text" v-model="item.value" placeholder="请输入" style="text-align: right;min-width: 400rpx;" class="color-9">
					</view>
				</view>
			</view>
			 -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				arrMoney: 0,
				money: '',
				user: wx.getStorageSync('userInfo'),
				car: [{
					name: '开户银行',
					value: wx.getStorageSync('userInfo').bank || ''
				}, {
					name: '账户名称',
					value: wx.getStorageSync('userInfo').bank_name || ''
				}, {
					name: '银行帐号',
					value: wx.getStorageSync('userInfo').bank_number || ''
				}],
				bankList:[],
				bankInfo:null
			}
		},
		onLoad(op) {
			this.arrMoney = op.money
		},
		methods: {
			toBind() {
				uni.navigateTo({
					url: '/pages/my/bankList'
				})
			},
			set() {
				if (this.money <= 0 || !this.money || this.money > this.user.money) {
					this.util.log(this.money > this.user.money ? '可提现金额不足' : '暂无可提现金额')
					return
				} else if (!this.bankInfo) {
					this.util.log('请选择提现银行卡')
				}
				this.util.req(this.api.apiWithdraw, {
					money: this.money,
					bank_id: this.bankInfo.id
				}).then(res => {
					this.util.log('已提交申请')
					setTimeout(() => {
						uni.navigateBack(1)
					}, 1000)
				})
			},
			handArr() {
				this.money = this.arrMoney;
			},
		}
	}
</script>
<style>
	page {
		background: #f5f5f5;
	}
</style>
<style lang="scss" scoped>
	.w {
		width: 100%;
	}
	.flex-1{
		flex:1;
	}
	.h-150 {
		height: 150rpx;
	}
	.border-b{
		border-bottom: 1px solid #eeeeee;
	}
	.box {
		background: #fff;
		border-radius: 16rpx;
		border: 2rpx solid #eee;
		margin-bottom: 36rpx;
	
		// padding: 28rpx 20rpx;
		// margin: 28rpx 32rpx;
		.top {
			border-bottom: 2rpx solid #eee;
			padding: 28rpx 0;
			margin-top: 20rpx;
		}
	
		.li {
			padding: 36rpx 0;
			border-bottom: 2rpx solid #eee;
		}
	
		.li:last-child {
			border: 0;
		}
	}
	
	.set {
		width: 688rpx;
		height: 92rpx;
		line-height: 92rpx;
		border-radius: 20rpx;
		text-align: center;
		margin: 0 auto;
	}
</style>